<?php
/*************************************************************************

  $Id: IclearBase.php 178 2009-06-04 11:14:54Z dis $

  iclear payment system - because secure is simply secure
  http://www.iclear.de

  Copyright (c) 2001 - 2009 iclear

  Released under the GNU General Public License

************************************************************************

                    All rights reserved.

  This program is free software licensed under the GNU General Public License (GPL).

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  USA

*************************************************************************/

  if(!defined('IC_SEC')) {
    die('No external calls allowed!');
  }

  class IclearBase {
    
    var $icCore = false;
    var $icError = false;
    
    var $icVersion = '';
    var $icWsdlVersion = IC_WSDL_VERSION;
    
	  // taken from w3c - utf8 detection
	  var $rxUTF8 = '/\A(
	     [\x09\x0A\x0D\x20-\x7E]            # ASCII
	   | [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte
	   |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs
	   | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
	   |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
	   |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3
	   | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
	   |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
	  )*\z/x';
    
    function IclearBase(&$icCore) {
      if(!is_object($icCore)) {
        die("No Core object detected!");
      }
      $this->icCore =& $icCore;
    }
    
    function version() {
    	return $this->icVersion;
    }
    
    function getLanguage() {
    	return $this->icCore->getLanguage();
    }
    
    function isError() {
      $fnc = __FUNCTION__;
    	return $this->icError->$fnc();
    }

    function addError($msg = '') {
    	$fnc = __FUNCTION__;
      return $this->icError->$fnc($msg);
    }

    function getErrorCount() {
      $fnc = __FUNCTION__;
    	return $this->icError->$fnc();
    }

    function dumpErrorList() {
      $fnc = __FUNCTION__;
    	return $this->icError->$fnc();
    }

    function getErrorString($lineBreak = "\n") {
      $fnc = __FUNCTION__;
    	return $this->icError->$fnc($lineBreak);
    }
    
    function lastError() {
      $fnc = __FUNCTION__;
      return $this->icError->$fnc();
    }
    
	  function encodeUTF8($string = '') {
	    if($string) {
	       if(!preg_match($this->rxUTF8, $string)) {
	         $string = utf8_encode($string);
	       }
	    }
	    return $string;
	  }
    
  
}// class



?>